package com.sky.controller.user;

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 小程序获取店铺状态
 *
 * @Author mr.lcc
 * @Data 2025/6/2 14:47
 */
@RestController
@RequestMapping("/user/shop")
@Slf4j
public class ShopStateController {

    @Autowired
    private RedisTemplate redisTemplate;

    public static final String KEY = "SHOP:STATUS";

    /**
     * 小程序获取到店铺的营业状态为
     *
     * @return
     */
    @GetMapping("/status")
    public Result getStatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get(KEY);
        log.info("获取到店铺的营业状态为:{}", status == 1 ? "营业中" : "店铺打烊中");
        return Result.success(status);
    }
}
